%{

extern int yyerror ( char* );
extern int yylex ();

#include "attributs.h"
#include "actions.h"

%}

%union{
	tAttrExpr attrExpr;
	tAttrInstr attrInstr;
	tAttrListInstr attrListInstr;
	
	tAttrEntier attrEntier;
	tAttrReel attrReel;
	tAttrIdent attrIdent;
}

%token < attrEntier > ENTIER
%token < attrReel > REEL
%token < attrIdent > IDENT

%token OP_ADD OP_SUB OP_MUL OP_DIV
%token OP_AFFECT

%start ListInstr

%type < attrExpr > Expr
%type < attrInstr > Instr
%type < attrListInstr > ListInstr

%%

ListInstr	:	Instr ListInstr			{ action_listinstr ( $$, $1, $2 ); }
			|							{ action_listinstr ( $$ ); }
			;

Instr		:	IDENT OP_AFFECT  Expr	{ action_instr ( $$, $1, $3 ); }
			;

Expr		:	OP_MUL Expr Expr	{ action_mul ( $$, $2, $3 ); }
			|	OP_DIV Expr Expr	{ action_div ( $$, $2, $3 ); }
			|	OP_ADD Expr Expr	{ action_add ( $$, $2, $3 ); }
			|	OP_SUB Expr Expr	{ action_sub ( $$, $2, $3 ); }
			|	ENTIER				{ action_constante ( $$, $1 ); }
			|	REEL				{ action_constante ( $$, $1 ); }
			|	IDENT				{ action_ident ( $$, $1 ); }
			;

%%
